/*
  广寒宫
  网址:www.guanghangong.xyz
 */
package org.moon.framework.sample.tenant.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.moon.framework.autoconfigure.tenant.annotation.NonDS;
import org.moon.framework.autoconfigure.tenant.annotation.TenantDS;
import org.moon.framework.sample.tenant.domain.query.UserQuery;
import org.moon.framework.sample.tenant.entity.SysUserEntity;
import org.moon.framework.sample.tenant.mapper.SysUserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 员工管理
 * @author moon
 */
@Service
public class SysUserService extends ServiceImpl<SysUserMapper, SysUserEntity> {


	@TenantDS
	public IPage<SysUserEntity> selectListPageByTenant(UserQuery query){
		IPage<SysUserEntity> page = new Page<SysUserEntity>(query.getPage(),query.getLimit());
		List<SysUserEntity> list = this.baseMapper.getUserListPage(page,query);
		page.setRecords(list);
		return page;
	}

	/**
	 * 手动写sql
	 */
	@NonDS
	public IPage<SysUserEntity> selectListPage(UserQuery query){
		IPage<SysUserEntity> page = new Page<SysUserEntity>(query.getPage(),query.getLimit());
		List<SysUserEntity> list = this.baseMapper.getUserListPage(page,query);
		page.setRecords(list);
		return page;
	}

	public IPage<SysUserEntity> selectListPageByGlobal(UserQuery query){
		IPage<SysUserEntity> page = new Page<SysUserEntity>(query.getPage(),query.getLimit());
		List<SysUserEntity> list = this.baseMapper.getUserListPage(page,query);
		page.setRecords(list);
		return page;
	}
}